package com.caigou.modules.channel.adapter

import android.text.TextUtils
import android.view.View
import android.widget.TextView
import com.caigou.comm.base.ext.levelName
import com.caigou.comm.base.utils.ImageLoader
import com.caigou.modules.channel.R
import com.caigou.modules.channel.bean.TeamItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/10/12
 */
class TeamItemAdapter(dataset: MutableList<TeamItemBean>) : BaseQuickAdapter<TeamItemBean, BaseViewHolder>(R.layout.item_team_list, dataset), LoadMoreModule {
    override fun convert(holder: BaseViewHolder, item: TeamItemBean) {
        if (!TextUtils.isEmpty(item.headImg)) {
            ImageLoader.loadCircle(context, item.headImg, holder.getView(R.id.team_item_iv_avatar))
        } else {
            holder.setImageResource(R.id.team_item_iv_avatar, R.drawable.img_comm_avatar)
        }
        holder.getView<TextView>(R.id.team_item_tv_name).text = item.nickName
        holder.getView<TextView>(R.id.team_item_tv_level).text = levelName(item.level)
        holder.getView<TextView>(R.id.team_item_tv_value).text = item.levelGrowthValue.toString()

        if (getItemPosition(item) == itemCount - 2) {
            holder.getView<View>(R.id.team_item_divider).visibility = View.GONE
        }
    }
}